package com.xxxx.protal.dao;

import com.xxxx.protal.pojo.Goods;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

/**
 * @author lwf
 * @title: GoodsRepository
 * @projectName shop
 * @description: TODO
 * @date 2021/1/515:32
 */
public interface GoodsRepository extends ElasticsearchRepository<Goods,Integer> {
    /**
     * 根据商品名查询
     * @param goodsName
     * @return
     */
    List<Goods> findByGoodsName(String goodsName);
    /**
     * 根据id查询商品
     * ？0为占位符
     * @param id
     * @return
     */
    @Query("{\"match\": {\"goodsId\":{ \"query\": \"?0\"}}}")
    Goods findByIdValue(Integer id);
}

